﻿using System.Collections.Generic;

namespace IceDog.DNL.CSharp.DesignPattern.CompositePattern.Supermarket
{
    /// <summary>
    /// 员工
    /// </summary>
    public class Employee
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 部门
        /// </summary>
        public string Departemnt { get; set; }
        /// <summary>
        /// 薪水
        /// </summary>
        public decimal Salary { get; set; }
        /// <summary>
        /// 下属
        /// </summary>
        public List<Employee> Subordinates { get; set; }
        /// <summary>Initializes a new instance of the 
        /// <see cref="T:IceDog.DNL.CSharp.DesignPattern.CompositePattern.Supermarket.Employee"></see> 
        /// class.</summary>
        public Employee(string name, string departemnt,decimal salary)
        {
            Name = name;
            Departemnt = departemnt;
            Salary = salary;
            Subordinates = new List<Employee>();
        }
        /// <summary>
        /// 添加下属
        /// </summary>
        /// <param name="employee"></param>
        public void AddSubordinate(Employee employee) => Subordinates.Add(employee);
        /// <summary>
        /// 移除下属
        /// </summary>
        /// <param name="employee"></param>
        public void RemoveSubordinate(Employee employee) => Subordinates.Remove(employee);

        /// <summary>Returns a string that represents the current object.</summary>
        /// <returns>A string that represents the current object.</returns>
        public override string ToString()
        {
            return $"{{name:{Name},Department:{Departemnt},Salary:{Salary},Subordinates Count:{Subordinates.Count}}}";
        }
    }
}
